package com.suray.basic.wcs.plc.pojo.oper;

import com.suray.basic.wcs.plc.core.PlcOffset;
import com.suray.basic.wcs.plc.enums.PlcDeviceType;
import com.suray.basic.wcs.plc.enums.Location;
import com.suray.basic.wcs.plc.pojo.DeviceBase;
import com.suray.basic.wcs.utils.Coord;

/**
 * @author shaozn
 * @date 2020/1/22 - 16:06
 * @Description 称重设备
 */
public class WeightingEquipmentOper extends DeviceBase {
    private static final PlcOffset CAN_READ = new PlcOffset(0, null);

    private static final PlcOffset WEIGHT_DATA = new PlcOffset(1, null);

    /**
     * 可读取
     * 0:无效  1:可读
     */
    private boolean canRead;
    /**
     * 重量结果
     */
    private int weightData;

    public WeightingEquipmentOper(PlcDeviceType plcDeviceType, int startNo, String deviceName, int deviceNo, Coord coord,
                                  Location location, Coord lockLocation, long deviceId, Integer gridzMax,
                                  Integer gridzRelative, int plcId) {
        super(plcDeviceType, startNo, deviceName, deviceNo, coord, location, lockLocation,deviceId,gridzMax,
                gridzRelative, plcId);
    }

    public boolean isCanRead() {
        return readPlc(CAN_READ) == 1;
    }

    public int getWeightData() {
        return readPlc(WEIGHT_DATA);
    }
}
